

setProvince();

function setProvince()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('province');
		DWRUtil.addOptions('province',{'':'请选择'});
		DWRUtil.addOptions('province',data);
	})
}
function setCitys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('eparchy_code');
		DWRUtil.addOptions('eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('eparchy_code',data);
		DWRUtil.removeAllOptions('city_code');
		DWRUtil.addOptions('city_code',{'':'请选择'});
	});
}

function setAreas(city_id){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions('city_code');
     	DWRUtil.addOptions('city_code',{'':'请选择'});
	 	DWRUtil.addOptions('city_code',data);
	});
}

function isCkecked(checksName){
	var checksArr = document.getElementsByName(checksName);
	if(checksArr){
		for(var i=0;i<checksArr.length;i++){
			if(checksArr[i].checked == true){
				return true;
			}
		}
	}
	return false;	
}


function subForm(){
	if(document.getElementById('nike_name').value==""){
				alert('请输入会员昵称！');
				document.getElementById('nike_name').focus();
				return false;
			}
		if(document.getElementById('user_name') != null) {
		if(document.getElementById('user_name').value==""){
				alert('请输入用户名！');
				document.getElementById('user_name').focus();
				return false;
			}
		if(document.getElementById('passwd').value==""){
				alert('请输入密码！');
				document.getElementById('passwd').focus();
				return false;
			}
		if(document.getElementById('cust_name').value==""){

				alert('请输入真实姓名！');

				document.getElementById('cust_name').focus();

				return false;

			}
			
			
			document.getElementById('real_name').value = document.getElementById('cust_name').value
			}

	
				var phone = document.getElementById('phone');
				var myreg2 =/^([0][1-9]{2,4}-)?[0-9]{5,8}$/;
			if(phone.value==""){

				alert('请输入电话号码！');

				document.getElementById('phone').focus();

				return false;

			}
			if(!myreg2.test(phone.value))
			{
			   alert('请输入有效的电话号码！');
			   document.getElementById('phone').focus();
			   return false;
			}
			
			var fax = document.getElementById('fax');
			if(fax!=""&&!myreg2.test(fax.value))
			{
			   alert('请输入有效的传真！');
			   document.getElementById('fax').focus();
			   return false;
			}
			
	var email = document.getElementById('email');
	 var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	 if(email !=null && email.value !="")
	 {
	   if(!myreg.test(email.value))
		 {
	     alert('请输入有效的E_mail！');
	     document.getElementById('email').focus();
	     return false;
		 }
		}
		var msn = document.getElementById('msn').value;
		if (msn!=null && msn.length!=0) {
          if (!myreg.test(msn))
          {
						alert("提示：您填写的msn无效，请填写一个有效的msn");
						   document.getElementById('msn').focus();
						return false;
          }
    }
		if(!isCkecked("marry")){
			alert('请选择婚姻状况！');
			return false;
		}
	   var cellphone = document.getElementById('cellphone').value;
	   var mobileReg =/^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/;
		if(cellphone !=null &&!mobileReg.test(cellphone)){
		      alert('请输入有效的手机号码！');
			  document.getElementById('cellphone').focus();
		      return false;
		}
		
		if(document.getElementById('user_class').value==""){

				alert('请选择会员级别！');

				document.getElementById('user_class').focus();

				return false;

			}		
		document.getElementById('cust_class').value = document.getElementById('user_class').value;	
			 //地区拼串
			var area_attr_str = "";
			if(document.getElementById("province").value!=""){
				area_attr_str += document.getElementById("province").value+"|";
				if(document.getElementById("eparchy_code").value!=""){
					area_attr_str += document.getElementById("eparchy_code").value+"|";
					if(document.getElementById("city_code").value!=""){
						area_attr_str += document.getElementById("city_code").value+"|";
					}
				}
			}
			if(area_attr_str==""){
				document.getElementById("area_attr").value = document.getElementById("area_attr_bak").value;
			}else{
				document.getElementById("area_attr").value = area_attr_str;
			}
		var post_code=document.getElementById("post_code").value;
			if(post_code!=""){
				if(post_code.length>6||post_code.length<6){
		  			alert("请输入6位数字邮政编码");
		  		    document.getElementById('post_code').focus();
				    return false;
				}
			}
		if(!isCkecked("sex")){
			alert('请选择性别！');
			return false;
		}


		     document.addForm.submit();
}



  
function isNum(){
	
			if(isNaN(document.getElementById('phone').value)){

				alert('内容必须是数字！');

				document.getElementById('phone').value="";
				document.getElementById('phone').focus();
				return false;

			}
			if(isNaN(document.getElementById('inter_num').value)){

				alert('内容必须是数字！');

				document.getElementById('inter_num').value="";
				document.getElementById('inter_num').focus();
				return false;

			}
				if(isNaN(document.getElementById('cellphone').value)){

				alert('内容必须是数字！');

				document.getElementById('cellphone').value="";
				document.getElementById('cellphone').focus();
				return false;

			}
				if(isNaN(document.getElementById('fax').value)){

				alert('内容必须是数字！');

				document.getElementById('fax').value="";
				document.getElementById('fax').focus();
				return false;

			}
				if(isNaN(document.getElementById('qq').value)){

				alert('内容必须是数字！');

				document.getElementById('qq').value="";
				document.getElementById('qq').focus();
				return false;

			}
				if(isNaN(document.getElementById('post_code').value)){

				alert('邮编必须是数字！');

				document.getElementById('post_code').value="";
				document.getElementById('post_code').focus();
				return false;

			}
	
	}

function ChangeOrg(){
	document.getElementById("org1").style.display = "none";
	document.getElementById("org2").style.display = "inline";
	document.getElementById("org_id").value = "";
}



	function searchForm(){
	 document.indexForm .submit();
	}
 function oper(val)
 {
    var size = document.getElementById('listsize').value;
		var all_news_id='';
		for(var i=0;i<size;i++){
			if(document.getElementById('checkone'+i).checked){
				all_news_id += document.getElementById('checkone'+i).value+'|';
			}
		}
		 document.getElementById('user_id').value = all_news_id;
		
		if(all_news_id==''){
			alert('请至少选择一条!');
			return false;
		}else{
   
    if(val=='0'){
    		  	document.indexForm.action='/doTradeReg.do';  //正常
    		  	document.getElementById("state_code").value="0";
	  			  document.getElementById("trade_type_code").value="1111";		
					  document.getElementById("bpm_id").value="1111";		
						document.indexForm.submit();
    }else if(val=='1'){  	
    	 			document.indexForm.action='/doTradeReg.do';//禁用
    	 			document.getElementById("state_code").value="1";
   	 			  document.getElementById("trade_type_code").value="1112";			
					  document.getElementById("bpm_id").value="1112";		
						document.indexForm.submit();
    }
  }
 }
 
 
 function ChangeOrg(){
	document.getElementById("org1").style.display = "none";
	document.getElementById("org2").style.display = "inline";
	//document.getElementById("org_id").value = "";
}

 
function submitPasswd(){
	if(document.getElementById("passwd").value == ""){
		alert("请填写用户密码！");
		document.getElementById("passwd").focus();
		return false;
	}
	
	if(document.getElementById("c_passwd").value == ""){
		alert("请填写确认密码！");
		document.getElementById("c_passwd").focus();
		return false;
	}
	
	if(document.getElementById("passwd").value != document.getElementById("c_passwd").value ){
		alert("两次输入的密码不一致！");
		document.getElementById("c_passwd").value = "";
		document.getElementById("c_passwd").focus();
		return false;
	}
	
	document.addForm.submit();
}